# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=soju
pkgver=0.4.0
pkgrel=3
pkgdesc="User-friendly IRC bouncer"
url="https://soju.im/"
license="AGPL-3.0"
arch="all"
pkgusers="$pkgname"
pkggroups="$pkgname"
install="$pkgname.pre-install"
depends="ca-certificates"
makedepends="go scdoc libcap sqlite-dev"
subpackages="$pkgname-openrc $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://git.sr.ht/~emersion/soju/archive/v$pkgver.tar.gz
	$pkgname.initd
	config.patch
	makefile.patch
	"
builddir="$srcdir/$pkgname-v$pkgver"

export GOFLAGS="$GOFLAGS -trimpath -mod=readonly -modcacherw -tags=libsqlite3"
export GOPATH="$srcdir"

build() {
	make GOFLAGS="$GOFLAGS"
}

check() {
	go test ./...
}

package() {
	make DESTDIR="$pkgdir" PREFIX=/usr install
	setcap cap_net_bind_service=+ep "$pkgdir"/usr/bin/soju

	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname

	# add additional docs
	install -Dm644 -t "$pkgdir"/usr/share/doc/$pkgname doc/*.md
}

sha512sums="
591e5666a110f64588ac8f76dd1c89d27e4c12f5b47a79bcb7d7d9911149ef5790d92aa83d9c7ae5f39641b3bac43637fa4887432ecabed2074f72961dfefd18  soju-0.4.0.tar.gz
a634ef93ea329a2cfb8c8c805d0ae66e1f6c9860efb297d558ddc2f874e061457e851a39a2075f122e8d9d9ee0f176b202bcc02d0360981cfc8b856cbd68cf01  soju.initd
48b0192bc385da4fe8c801612aed6b85accb84b9435f8f590b251bbeb1362567da6676e487ba6535561050a42efa84d9a712dc843482190ccd1483c0e2f12fa8  config.patch
599a809aa78406bc029ee63b4e7a8e8825972a397626529adce75c38c27f3d2b326335cac287b251344775f8735a9a47c8e35545df33a9d659d3ddac1bb575d5  makefile.patch
"
